﻿using System;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Text;
using HslCommunication.BasicFramework;
using HslCommunication.Core;
using HslCommunication.Core.Address;
using HslCommunication.Core.Net;
using HslCommunication.LogNet;
using HslCommunication.Reflection;

namespace HslCommunication.Profinet.Yokogawa
{
	/// <summary>
	/// <b>[商业授权]</b> 横河PLC的虚拟服务器，支持X,Y,I,E,M,T,C,L继电器类型的数据读写，支持D,B,F,R,V,Z,W,TN,CN寄存器类型的数据读写，可以用来测试横河PLC的二进制通信类型<br />
	/// <b>[Authorization]</b> Yokogawa PLC's virtual server, supports X, Y, I, E, M, T, C, L relay type data read and write, 
	/// supports D, B, F, R, V, Z, W, TN, CN register types The data read and write can be used to test the binary communication type of Yokogawa PLC
	/// </summary>
	/// <remarks>
	/// 其中的X继电器可以在服务器进行读写操作，但是远程的PLC只能进行读取，所有的数据读写的最大的范围按照协议进行了限制。
	/// </remarks>
	/// <example>
	/// 地址示例如下：
	/// <list type="table">
	///   <listheader>
	///     <term>地址名称</term>
	///     <term>地址代号</term>
	///     <term>示例</term>
	///     <term>字操作</term>
	///     <term>位操作</term>
	///     <term>备注</term>
	///   </listheader>
	///   <item>
	///     <term>Input relay</term>
	///     <term>X</term>
	///     <term>X100,X200</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term>服务器端可读可写</term>
	///   </item>
	///   <item>
	///     <term>Output relay</term>
	///     <term>Y</term>
	///     <term>Y100,Y200</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Internal relay</term>
	///     <term>I</term>
	///     <term>I100,I200</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Share relay</term>
	///     <term>E</term>
	///     <term>E100,E200</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Special relay</term>
	///     <term>M</term>
	///     <term>M100,M200</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Time relay</term>
	///     <term>T</term>
	///     <term>T100,T200</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Counter relay</term>
	///     <term>C</term>
	///     <term>C100,C200</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>link relay</term>
	///     <term>L</term>
	///     <term>L100, L200</term>
	///     <term>√</term>
	///     <term>√</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Data register</term>
	///     <term>D</term>
	///     <term>D100,D200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>File register</term>
	///     <term>B</term>
	///     <term>B100,B200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Cache register</term>
	///     <term>F</term>
	///     <term>F100,F200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Shared register</term>
	///     <term>R</term>
	///     <term>R100,R200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Index register</term>
	///     <term>V</term>
	///     <term>V100,V200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Special register</term>
	///     <term>Z</term>
	///     <term>Z100,Z200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Link register</term>
	///     <term>W</term>
	///     <term>W100,W200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Timer current value</term>
	///     <term>TN</term>
	///     <term>TN100,TN200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	///   <item>
	///     <term>Counter current value</term>
	///     <term>CN</term>
	///     <term>CN100,CN200</term>
	///     <term>√</term>
	///     <term>×</term>
	///     <term></term>
	///   </item>
	/// </list>
	/// 你可以很快速并且简单的创建一个虚拟的横河服务器
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Profinet\YokogawaLinkServerSample.cs" region="UseExample1" title="简单的创建服务器" />
	/// 当然如果需要高级的服务器，指定日志，限制客户端的IP地址，获取客户端发送的信息，在服务器初始化的时候就要参照下面的代码：
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Profinet\YokogawaLinkServerSample.cs" region="UseExample4" title="定制服务器" />
	/// 服务器创建好之后，我们就可以对服务器进行一些读写的操作了，下面的代码是基础的BCL类型的读写操作。
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Profinet\YokogawaLinkServerSample.cs" region="ReadWriteExample" title="基础的读写示例" />
	/// 高级的对于byte数组类型的数据进行批量化的读写操作如下：   
	/// <code lang="cs" source="HslCommunication_Net45.Test\Documentation\Samples\Profinet\YokogawaLinkServerSample.cs" region="BytesReadWrite" title="字节的读写示例" />
	/// 更高级操作请参见源代码。
	/// </example>
	// Token: 0x02000040 RID: 64
	public class YokogawaLinkServer : NetworkDataServerBase
	{
		/// <summary>
		/// 实例化一个横河PLC的服务器，支持X,Y,I,E,M,T,C,L继电器类型的数据读写，支持D,B,F,R,V,Z,W,TN,CN寄存器类型的数据读写<br />
		/// Instantiate a Yokogawa PLC server, support X, Y, I, E, M, T, C, L relay type data read and write, 
		/// support D, B, F, R, V, Z, W, TN, CN Register type data reading and writing
		/// </summary>
		// Token: 0x06000551 RID: 1361 RVA: 0x00015E54 File Offset: 0x00014054
		public YokogawaLinkServer()
		{
			this.xBuffer = new SoftBuffer(65536);
			this.yBuffer = new SoftBuffer(65536);
			this.iBuffer = new SoftBuffer(65536);
			this.eBuffer = new SoftBuffer(65536);
			this.mBuffer = new SoftBuffer(65536);
			this.lBuffer = new SoftBuffer(65536);
			this.dBuffer = new SoftBuffer(131072);
			this.bBuffer = new SoftBuffer(131072);
			this.fBuffer = new SoftBuffer(131072);
			this.rBuffer = new SoftBuffer(131072);
			this.vBuffer = new SoftBuffer(131072);
			this.zBuffer = new SoftBuffer(131072);
			this.wBuffer = new SoftBuffer(131072);
			this.specialBuffer = new SoftBuffer(131072);
			base.WordLength = 2;
			base.ByteTransform = new ReverseWordTransform();
			base.ByteTransform.DataFormat = DataFormat.CDAB;
			this.transform = new ReverseBytesTransform();
		}

		// Token: 0x06000552 RID: 1362 RVA: 0x00015F7C File Offset: 0x0001417C
		private OperateResult<SoftBuffer> GetDataAreaFromYokogawaAddress(YokogawaLinkAddress yokogawaAddress, bool isBit)
		{
			OperateResult<SoftBuffer> result;
			if (isBit)
			{
				int dataCode = yokogawaAddress.DataCode;
				int num = dataCode;
				if (num <= 13)
				{
					if (num == 5)
					{
						return OperateResult.CreateSuccessResult<SoftBuffer>(this.eBuffer);
					}
					switch (num)
					{
					case 9:
						return OperateResult.CreateSuccessResult<SoftBuffer>(this.iBuffer);
					case 12:
						return OperateResult.CreateSuccessResult<SoftBuffer>(this.lBuffer);
					case 13:
						return OperateResult.CreateSuccessResult<SoftBuffer>(this.mBuffer);
					}
				}
				else
				{
					if (num == 24)
					{
						return OperateResult.CreateSuccessResult<SoftBuffer>(this.xBuffer);
					}
					if (num == 25)
					{
						return OperateResult.CreateSuccessResult<SoftBuffer>(this.yBuffer);
					}
				}
				result = new OperateResult<SoftBuffer>(StringResources.Language.NotSupportedDataType);
			}
			else
			{
				switch (yokogawaAddress.DataCode)
				{
				case 2:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.bBuffer);
				case 4:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.dBuffer);
				case 5:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.eBuffer);
				case 6:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.fBuffer);
				case 9:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.iBuffer);
				case 12:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.lBuffer);
				case 13:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.mBuffer);
				case 18:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.rBuffer);
				case 22:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.vBuffer);
				case 23:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.wBuffer);
				case 24:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.xBuffer);
				case 25:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.yBuffer);
				case 26:
					return OperateResult.CreateSuccessResult<SoftBuffer>(this.zBuffer);
				}
				result = new OperateResult<SoftBuffer>(StringResources.Language.NotSupportedDataType);
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.Yokogawa.YokogawaLinkTcp.Read(System.String,System.UInt16)" />
		// Token: 0x06000553 RID: 1363 RVA: 0x000161A8 File Offset: 0x000143A8
		[HslMqttApi("ReadByteArray", "")]
		public override OperateResult<byte[]> Read(string address, ushort length)
		{
			bool flag = address.StartsWith("Special:") || address.StartsWith("special:");
			if (flag)
			{
				address = address.Substring(8);
				OperateResult<int> operateResult = HslHelper.ExtractParameter(ref address, "unit");
				OperateResult<int> operateResult2 = HslHelper.ExtractParameter(ref address, "slot");
				try
				{
					return OperateResult.CreateSuccessResult<byte[]>(this.specialBuffer.GetBytes((int)(ushort.Parse(address) * 2), (int)(length * 2)));
				}
				catch (Exception ex)
				{
					return new OperateResult<byte[]>("Address format wrong: " + ex.Message);
				}
			}
			OperateResult<YokogawaLinkAddress> operateResult3 = YokogawaLinkAddress.ParseFrom(address, length);
			bool flag2 = !operateResult3.IsSuccess;
			OperateResult<byte[]> result;
			if (flag2)
			{
				result = OperateResult.CreateFailedResult<byte[]>(operateResult3);
			}
			else
			{
				OperateResult<SoftBuffer> dataAreaFromYokogawaAddress = this.GetDataAreaFromYokogawaAddress(operateResult3.Content, false);
				bool flag3 = !dataAreaFromYokogawaAddress.IsSuccess;
				if (flag3)
				{
					result = OperateResult.CreateFailedResult<byte[]>(dataAreaFromYokogawaAddress);
				}
				else
				{
					bool flag4 = operateResult3.Content.DataCode == 24 || operateResult3.Content.DataCode == 25 || operateResult3.Content.DataCode == 9 || operateResult3.Content.DataCode == 5 || operateResult3.Content.DataCode == 13 || operateResult3.Content.DataCode == 12;
					if (flag4)
					{
						result = OperateResult.CreateSuccessResult<byte[]>(Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(dataAreaFromYokogawaAddress.Content.GetBytes(operateResult3.Content.AddressStart, (int)(length * 16)), (byte m) => m > 0)).ToByteArray());
					}
					else
					{
						result = OperateResult.CreateSuccessResult<byte[]>(dataAreaFromYokogawaAddress.Content.GetBytes(operateResult3.Content.AddressStart * 2, (int)(length * 2)));
					}
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.Yokogawa.YokogawaLinkTcp.Write(System.String,System.Byte[])" />
		// Token: 0x06000554 RID: 1364 RVA: 0x00016378 File Offset: 0x00014578
		[HslMqttApi("WriteByteArray", "")]
		public override OperateResult Write(string address, byte[] value)
		{
			bool flag = address.StartsWith("Special:") || address.StartsWith("special:");
			if (flag)
			{
				address = address.Substring(8);
				OperateResult<int> operateResult = HslHelper.ExtractParameter(ref address, "unit");
				OperateResult<int> operateResult2 = HslHelper.ExtractParameter(ref address, "slot");
				try
				{
					this.specialBuffer.SetBytes(value, (int)(ushort.Parse(address) * 2));
					return OperateResult.CreateSuccessResult();
				}
				catch (Exception ex)
				{
					return new OperateResult("Address format wrong: " + ex.Message);
				}
			}
			OperateResult<YokogawaLinkAddress> operateResult3 = YokogawaLinkAddress.ParseFrom(address, 0);
			bool flag2 = !operateResult3.IsSuccess;
			OperateResult result;
			if (flag2)
			{
				result = OperateResult.CreateFailedResult<byte[]>(operateResult3);
			}
			else
			{
				OperateResult<SoftBuffer> dataAreaFromYokogawaAddress = this.GetDataAreaFromYokogawaAddress(operateResult3.Content, false);
				bool flag3 = !dataAreaFromYokogawaAddress.IsSuccess;
				if (flag3)
				{
					result = OperateResult.CreateFailedResult<byte[]>(dataAreaFromYokogawaAddress);
				}
				else
				{
					bool flag4 = operateResult3.Content.DataCode == 24 || operateResult3.Content.DataCode == 25 || operateResult3.Content.DataCode == 9 || operateResult3.Content.DataCode == 5 || operateResult3.Content.DataCode == 13 || operateResult3.Content.DataCode == 12;
					if (flag4)
					{
						dataAreaFromYokogawaAddress.Content.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(value.ToBoolArray(), (bool m) => m ? 1 : 0)), operateResult3.Content.AddressStart);
					}
					else
					{
						dataAreaFromYokogawaAddress.Content.SetBytes(value, operateResult3.Content.AddressStart * 2);
					}
					result = OperateResult.CreateSuccessResult();
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.Yokogawa.YokogawaLinkTcp.ReadBool(System.String,System.UInt16)" />
		// Token: 0x06000555 RID: 1365 RVA: 0x0001653C File Offset: 0x0001473C
		[HslMqttApi("ReadBoolArray", "")]
		public override OperateResult<bool[]> ReadBool(string address, ushort length)
		{
			OperateResult<YokogawaLinkAddress> operateResult = YokogawaLinkAddress.ParseFrom(address, length);
			bool flag = !operateResult.IsSuccess;
			OperateResult<bool[]> result;
			if (flag)
			{
				result = OperateResult.CreateFailedResult<bool[]>(operateResult);
			}
			else
			{
				OperateResult<SoftBuffer> dataAreaFromYokogawaAddress = this.GetDataAreaFromYokogawaAddress(operateResult.Content, true);
				bool flag2 = !dataAreaFromYokogawaAddress.IsSuccess;
				if (flag2)
				{
					result = OperateResult.CreateFailedResult<bool[]>(dataAreaFromYokogawaAddress);
				}
				else
				{
					result = OperateResult.CreateSuccessResult<bool[]>(Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.mBuffer.GetBytes(operateResult.Content.AddressStart, (int)length), (byte m) => m > 0)));
				}
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Profinet.Yokogawa.YokogawaLinkTcp.Write(System.String,System.Boolean[])" />
		// Token: 0x06000556 RID: 1366 RVA: 0x000165D8 File Offset: 0x000147D8
		[HslMqttApi("WriteBoolArray", "")]
		public override OperateResult Write(string address, bool[] value)
		{
			OperateResult<YokogawaLinkAddress> operateResult = YokogawaLinkAddress.ParseFrom(address, 0);
			bool flag = !operateResult.IsSuccess;
			OperateResult result;
			if (flag)
			{
				result = operateResult;
			}
			else
			{
				OperateResult<SoftBuffer> dataAreaFromYokogawaAddress = this.GetDataAreaFromYokogawaAddress(operateResult.Content, true);
				bool flag2 = !dataAreaFromYokogawaAddress.IsSuccess;
				if (flag2)
				{
					result = dataAreaFromYokogawaAddress;
				}
				else
				{
					dataAreaFromYokogawaAddress.Content.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(value, (bool m) => m ? 1 : 0)), operateResult.Content.AddressStart);
					result = OperateResult.CreateSuccessResult();
				}
			}
			return result;
		}

		/// <summary>
		/// 如果未执行程序，则开始执行程序<br />
		/// Starts executing a program if it is not being executed
		/// </summary>
		// Token: 0x06000557 RID: 1367 RVA: 0x0001666A File Offset: 0x0001486A
		[HslMqttApi(Description = "Starts executing a program if it is not being executed")]
		public void StartProgram()
		{
			this.isProgramStarted = true;
		}

		/// <summary>
		/// 停止当前正在执行程序<br />
		/// Stops the executing program.
		/// </summary>
		// Token: 0x06000558 RID: 1368 RVA: 0x00016674 File Offset: 0x00014874
		[HslMqttApi(Description = "Stops the executing program.")]
		public void StopProgram()
		{
			this.isProgramStarted = false;
		}

		/// <inheritdoc />
		// Token: 0x06000559 RID: 1369 RVA: 0x00016680 File Offset: 0x00014880
		protected override void ThreadPoolLoginAfterClientCheck(Socket socket, IPEndPoint endPoint)
		{
			AppSession appSession = new AppSession();
			appSession.IpEndPoint = endPoint;
			appSession.WorkSocket = socket;
			try
			{
				socket.BeginReceive(new byte[0], 0, 0, SocketFlags.None, new AsyncCallback(this.SocketAsyncCallBack), appSession);
				base.AddClient(appSession);
			}
			catch
			{
				socket.Close();
				ILogNet logNet = base.LogNet;
				if (logNet != null)
				{
					logNet.WriteDebug(this.ToString(), string.Format(StringResources.Language.ClientOfflineInfo, endPoint));
				}
			}
		}

		// Token: 0x0600055A RID: 1370 RVA: 0x00016714 File Offset: 0x00014914
		[DebuggerStepThrough]
		private void SocketAsyncCallBack(IAsyncResult ar)
		{
			YokogawaLinkServer.<SocketAsyncCallBack>d__9 <SocketAsyncCallBack>d__ = new YokogawaLinkServer.<SocketAsyncCallBack>d__9();
			<SocketAsyncCallBack>d__.<>t__builder = AsyncVoidMethodBuilder.Create();
			<SocketAsyncCallBack>d__.<>4__this = this;
			<SocketAsyncCallBack>d__.ar = ar;
			<SocketAsyncCallBack>d__.<>1__state = -1;
			<SocketAsyncCallBack>d__.<>t__builder.Start<YokogawaLinkServer.<SocketAsyncCallBack>d__9>(ref <SocketAsyncCallBack>d__);
		}

		// Token: 0x0600055B RID: 1371 RVA: 0x00016754 File Offset: 0x00014954
		private byte[] ReadBoolByCommand(byte[] command)
		{
			int num = this.transform.TransInt32(command, 6);
			int num2 = (int)this.transform.TransUInt16(command, 10);
			bool flag = num > 65535 || num < 0;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 4, null);
			}
			else
			{
				bool flag2 = num2 > 256;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					bool flag3 = num + num2 > 65535;
					if (flag3)
					{
						result = this.PackCommandBack(command[0], 5, null);
					}
					else
					{
						byte b = command[5];
						byte b2 = b;
						if (b2 <= 13)
						{
							if (b2 == 5)
							{
								return this.PackCommandBack(command[0], 0, this.eBuffer.GetBytes(num, num2));
							}
							switch (b2)
							{
							case 9:
								return this.PackCommandBack(command[0], 0, this.iBuffer.GetBytes(num, num2));
							case 12:
								return this.PackCommandBack(command[0], 0, this.lBuffer.GetBytes(num, num2));
							case 13:
								return this.PackCommandBack(command[0], 0, this.mBuffer.GetBytes(num, num2));
							}
						}
						else
						{
							if (b2 == 24)
							{
								return this.PackCommandBack(command[0], 0, this.xBuffer.GetBytes(num, num2));
							}
							if (b2 == 25)
							{
								return this.PackCommandBack(command[0], 0, this.yBuffer.GetBytes(num, num2));
							}
						}
						result = this.PackCommandBack(command[0], 3, null);
					}
				}
			}
			return result;
		}

		// Token: 0x0600055C RID: 1372 RVA: 0x000168E0 File Offset: 0x00014AE0
		private byte[] WriteBoolByCommand(byte[] command)
		{
			int num = this.transform.TransInt32(command, 6);
			int num2 = (int)this.transform.TransUInt16(command, 10);
			bool flag = num > 65535 || num < 0;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 4, null);
			}
			else
			{
				bool flag2 = num2 > 256;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					bool flag3 = num + num2 > 65535;
					if (flag3)
					{
						result = this.PackCommandBack(command[0], 5, null);
					}
					else
					{
						bool flag4 = num2 != command.Length - 12;
						if (flag4)
						{
							result = this.PackCommandBack(command[0], 5, null);
						}
						else
						{
							byte b = command[5];
							byte b2 = b;
							if (b2 <= 13)
							{
								if (b2 == 5)
								{
									this.eBuffer.SetBytes(command.RemoveBegin(12), num);
									return this.PackCommandBack(command[0], 0, null);
								}
								switch (b2)
								{
								case 9:
									this.iBuffer.SetBytes(command.RemoveBegin(12), num);
									return this.PackCommandBack(command[0], 0, null);
								case 12:
									this.lBuffer.SetBytes(command.RemoveBegin(12), num);
									return this.PackCommandBack(command[0], 0, null);
								case 13:
									this.mBuffer.SetBytes(command.RemoveBegin(12), num);
									return this.PackCommandBack(command[0], 0, null);
								}
							}
							else
							{
								if (b2 == 24)
								{
									return this.PackCommandBack(command[0], 3, null);
								}
								if (b2 == 25)
								{
									this.yBuffer.SetBytes(command.RemoveBegin(12), num);
									return this.PackCommandBack(command[0], 0, null);
								}
							}
							result = this.PackCommandBack(command[0], 3, null);
						}
					}
				}
			}
			return result;
		}

		// Token: 0x0600055D RID: 1373 RVA: 0x00016AB4 File Offset: 0x00014CB4
		private byte[] ReadRandomBoolByCommand(byte[] command)
		{
			int num = (int)this.transform.TransUInt16(command, 4);
			bool flag = num > 32;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 5, null);
			}
			else
			{
				bool flag2 = num * 6 != command.Length - 6;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					byte[] array = new byte[num];
					int i = 0;
					while (i < num)
					{
						int num2 = this.transform.TransInt32(command, 8 + 6 * i);
						bool flag3 = num2 > 65535 || num2 < 0;
						if (flag3)
						{
							return this.PackCommandBack(command[0], 4, null);
						}
						byte b = command[7 + i * 6];
						byte b2 = b;
						if (b2 <= 13)
						{
							if (b2 != 5)
							{
								switch (b2)
								{
								case 9:
									array[i] = this.iBuffer.GetBytes(num2, 1)[0];
									break;
								case 10:
								case 11:
									goto IL_16E;
								case 12:
									array[i] = this.lBuffer.GetBytes(num2, 1)[0];
									break;
								case 13:
									array[i] = this.mBuffer.GetBytes(num2, 1)[0];
									break;
								default:
									goto IL_16E;
								}
							}
							else
							{
								array[i] = this.eBuffer.GetBytes(num2, 1)[0];
							}
						}
						else if (b2 != 24)
						{
							if (b2 != 25)
							{
								goto IL_16E;
							}
							array[i] = this.yBuffer.GetBytes(num2, 1)[0];
						}
						else
						{
							array[i] = this.xBuffer.GetBytes(num2, 1)[0];
						}
						i++;
						continue;
						IL_16E:
						return this.PackCommandBack(command[0], 3, null);
					}
					result = this.PackCommandBack(command[0], 0, array);
				}
			}
			return result;
		}

		// Token: 0x0600055E RID: 1374 RVA: 0x00016C64 File Offset: 0x00014E64
		private byte[] WriteRandomBoolByCommand(byte[] command)
		{
			int num = (int)this.transform.TransUInt16(command, 4);
			bool flag = num > 32;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 5, null);
			}
			else
			{
				bool flag2 = num * 8 - 1 != command.Length - 6;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					int i = 0;
					while (i < num)
					{
						int num2 = this.transform.TransInt32(command, 8 + 8 * i);
						bool flag3 = num2 > 65535 || num2 < 0;
						if (flag3)
						{
							return this.PackCommandBack(command[0], 4, null);
						}
						byte b = command[7 + i * 8];
						byte b2 = b;
						if (b2 <= 13)
						{
							if (b2 != 5)
							{
								switch (b2)
								{
								case 9:
									this.iBuffer.SetValue(command[12 + 8 * i], num2);
									break;
								case 10:
								case 11:
									goto IL_171;
								case 12:
									this.lBuffer.SetValue(command[12 + 8 * i], num2);
									break;
								case 13:
									this.mBuffer.SetValue(command[12 + 8 * i], num2);
									break;
								default:
									goto IL_171;
								}
							}
							else
							{
								this.eBuffer.SetValue(command[12 + 8 * i], num2);
							}
						}
						else
						{
							if (b2 == 24)
							{
								return this.PackCommandBack(command[0], 3, null);
							}
							if (b2 != 25)
							{
								goto IL_171;
							}
							this.yBuffer.SetValue(command[12 + 8 * i], num2);
						}
						i++;
						continue;
						IL_171:
						return this.PackCommandBack(command[0], 3, null);
					}
					result = this.PackCommandBack(command[0], 0, null);
				}
			}
			return result;
		}

		// Token: 0x0600055F RID: 1375 RVA: 0x00016E14 File Offset: 0x00015014
		private byte[] ReadWordByCommand(byte[] command)
		{
			int num = this.transform.TransInt32(command, 6);
			int num2 = (int)this.transform.TransUInt16(command, 10);
			bool flag = num > 65535 || num < 0;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 4, null);
			}
			else
			{
				bool flag2 = num2 > 64;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					bool flag3 = num + num2 > 65535;
					if (flag3)
					{
						result = this.PackCommandBack(command[0], 5, null);
					}
					else
					{
						switch (command[5])
						{
						case 2:
							return this.PackCommandBack(command[0], 0, this.bBuffer.GetBytes(num * 2, num2 * 2));
						case 4:
							return this.PackCommandBack(command[0], 0, this.dBuffer.GetBytes(num * 2, num2 * 2));
						case 5:
							return this.PackCommandBack(command[0], 0, Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.eBuffer.GetBytes(num, num2 * 16), (byte m) => m > 0)).ToByteArray());
						case 6:
							return this.PackCommandBack(command[0], 0, this.fBuffer.GetBytes(num * 2, num2 * 2));
						case 9:
							return this.PackCommandBack(command[0], 0, Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.iBuffer.GetBytes(num, num2 * 16), (byte m) => m > 0)).ToByteArray());
						case 12:
							return this.PackCommandBack(command[0], 0, Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.lBuffer.GetBytes(num, num2 * 16), (byte m) => m > 0)).ToByteArray());
						case 13:
							return this.PackCommandBack(command[0], 0, Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.mBuffer.GetBytes(num, num2 * 16), (byte m) => m > 0)).ToByteArray());
						case 18:
							return this.PackCommandBack(command[0], 0, this.rBuffer.GetBytes(num * 2, num2 * 2));
						case 22:
							return this.PackCommandBack(command[0], 0, this.vBuffer.GetBytes(num * 2, num2 * 2));
						case 23:
							return this.PackCommandBack(command[0], 0, this.wBuffer.GetBytes(num * 2, num2 * 2));
						case 24:
							return this.PackCommandBack(command[0], 0, Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.xBuffer.GetBytes(num, num2 * 16), (byte m) => m > 0)).ToByteArray());
						case 25:
							return this.PackCommandBack(command[0], 0, Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.yBuffer.GetBytes(num, num2 * 16), (byte m) => m > 0)).ToByteArray());
						case 26:
							return this.PackCommandBack(command[0], 0, this.zBuffer.GetBytes(num * 2, num2 * 2));
						}
						result = this.PackCommandBack(command[0], 3, null);
					}
				}
			}
			return result;
		}

		// Token: 0x06000560 RID: 1376 RVA: 0x000171DC File Offset: 0x000153DC
		private byte[] WriteWordByCommand(byte[] command)
		{
			int num = this.transform.TransInt32(command, 6);
			int num2 = (int)this.transform.TransUInt16(command, 10);
			bool flag = num > 65535 || num < 0;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 4, null);
			}
			else
			{
				bool flag2 = num2 > 64;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					bool flag3 = num + num2 > 65535;
					if (flag3)
					{
						result = this.PackCommandBack(command[0], 5, null);
					}
					else
					{
						bool flag4 = num2 * 2 != command.Length - 12;
						if (flag4)
						{
							result = this.PackCommandBack(command[0], 5, null);
						}
						else
						{
							switch (command[5])
							{
							case 2:
								this.bBuffer.SetBytes(command.RemoveBegin(12), num * 2);
								return this.PackCommandBack(command[0], 0, null);
							case 4:
								this.dBuffer.SetBytes(command.RemoveBegin(12), num * 2);
								return this.PackCommandBack(command[0], 0, null);
							case 5:
								this.eBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.RemoveBegin(12).ToBoolArray(), (bool m) => m ? 1 : 0)), num);
								return this.PackCommandBack(command[0], 0, null);
							case 6:
								this.fBuffer.SetBytes(command.RemoveBegin(12), num * 2);
								return this.PackCommandBack(command[0], 0, null);
							case 9:
								this.iBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.RemoveBegin(12).ToBoolArray(), (bool m) => m ? 1 : 0)), num);
								return this.PackCommandBack(command[0], 0, null);
							case 12:
								this.lBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.RemoveBegin(12).ToBoolArray(), (bool m) => m ? 1 : 0)), num);
								return this.PackCommandBack(command[0], 0, null);
							case 13:
								this.mBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.RemoveBegin(12).ToBoolArray(), (bool m) => m ? 1 : 0)), num);
								return this.PackCommandBack(command[0], 0, null);
							case 18:
								this.rBuffer.SetBytes(command.RemoveBegin(12), num * 2);
								return this.PackCommandBack(command[0], 0, null);
							case 22:
								this.vBuffer.SetBytes(command.RemoveBegin(12), num * 2);
								return this.PackCommandBack(command[0], 0, null);
							case 23:
								this.wBuffer.SetBytes(command.RemoveBegin(12), num * 2);
								return this.PackCommandBack(command[0], 0, null);
							case 24:
								return this.PackCommandBack(command[0], 3, null);
							case 25:
								this.yBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.RemoveBegin(12).ToBoolArray(), (bool m) => m ? 1 : 0)), num);
								return this.PackCommandBack(command[0], 0, null);
							case 26:
								this.zBuffer.SetBytes(command.RemoveBegin(12), num * 2);
								return this.PackCommandBack(command[0], 0, null);
							}
							result = this.PackCommandBack(command[0], 3, null);
						}
					}
				}
			}
			return result;
		}

		// Token: 0x06000561 RID: 1377 RVA: 0x000175D8 File Offset: 0x000157D8
		private byte[] ReadRandomWordByCommand(byte[] command)
		{
			int num = (int)this.transform.TransUInt16(command, 4);
			bool flag = num > 32;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 5, null);
			}
			else
			{
				bool flag2 = num * 6 != command.Length - 6;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					byte[] array = new byte[num * 2];
					int i = 0;
					while (i < num)
					{
						int num2 = this.transform.TransInt32(command, 8 + 6 * i);
						bool flag3 = num2 > 65535 || num2 < 0;
						if (flag3)
						{
							return this.PackCommandBack(command[0], 4, null);
						}
						switch (command[7 + i * 6])
						{
						case 2:
							this.bBuffer.GetBytes(num2 * 2, 2).CopyTo(array, i * 2);
							break;
						case 3:
						case 7:
						case 8:
						case 10:
						case 11:
						case 14:
						case 15:
						case 16:
						case 17:
						case 19:
						case 20:
						case 21:
							goto IL_3BD;
						case 4:
							this.dBuffer.GetBytes(num2 * 2, 2).CopyTo(array, i * 2);
							break;
						case 5:
							Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.eBuffer.GetBytes(num2, 16), (byte m) => m > 0)).ToByteArray().CopyTo(array, i * 2);
							break;
						case 6:
							this.fBuffer.GetBytes(num2 * 2, 2).CopyTo(array, i * 2);
							break;
						case 9:
							Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.iBuffer.GetBytes(num2, 16), (byte m) => m > 0)).ToByteArray().CopyTo(array, i * 2);
							break;
						case 12:
							Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.lBuffer.GetBytes(num2, 16), (byte m) => m > 0)).ToByteArray().CopyTo(array, i * 2);
							break;
						case 13:
							Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.mBuffer.GetBytes(num2, 16), (byte m) => m > 0)).ToByteArray().CopyTo(array, i * 2);
							break;
						case 18:
							this.rBuffer.GetBytes(num2 * 2, 2).CopyTo(array, i * 2);
							break;
						case 22:
							this.vBuffer.GetBytes(num2 * 2, 2).CopyTo(array, i * 2);
							break;
						case 23:
							this.wBuffer.GetBytes(num2 * 2, 2).CopyTo(array, i * 2);
							break;
						case 24:
							Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.xBuffer.GetBytes(num2, 16), (byte m) => m > 0)).ToByteArray().CopyTo(array, i * 2);
							break;
						case 25:
							Enumerable.ToArray<bool>(Enumerable.Select<byte, bool>(this.yBuffer.GetBytes(num2, 16), (byte m) => m > 0)).ToByteArray().CopyTo(array, i * 2);
							break;
						case 26:
							this.zBuffer.GetBytes(num2 * 2, 2).CopyTo(array, i * 2);
							break;
						default:
							goto IL_3BD;
						}
						i++;
						continue;
						IL_3BD:
						return this.PackCommandBack(command[0], 3, null);
					}
					result = this.PackCommandBack(command[0], 0, array);
				}
			}
			return result;
		}

		// Token: 0x06000562 RID: 1378 RVA: 0x000179D4 File Offset: 0x00015BD4
		private byte[] WriteRandomWordByCommand(byte[] command)
		{
			int num = (int)this.transform.TransUInt16(command, 4);
			bool flag = num > 32;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 5, null);
			}
			else
			{
				bool flag2 = num * 8 != command.Length - 6;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					int i = 0;
					while (i < num)
					{
						int num2 = this.transform.TransInt32(command, 8 + 8 * i);
						bool flag3 = num2 > 65535 || num2 < 0;
						if (flag3)
						{
							return this.PackCommandBack(command[0], 4, null);
						}
						switch (command[7 + i * 8])
						{
						case 2:
							this.bBuffer.SetBytes(command.SelectMiddle(12 + 8 * i, 2), num2 * 2);
							break;
						case 3:
						case 7:
						case 8:
						case 10:
						case 11:
						case 14:
						case 15:
						case 16:
						case 17:
						case 19:
						case 20:
						case 21:
							goto IL_395;
						case 4:
							this.dBuffer.SetBytes(command.SelectMiddle(12 + 8 * i, 2), num2 * 2);
							break;
						case 5:
							this.eBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.SelectMiddle(12 + 8 * i, 2).ToBoolArray(), (bool m) => m ? 1 : 0)), num2);
							break;
						case 6:
							this.fBuffer.SetBytes(command.SelectMiddle(12 + 8 * i, 2), num2 * 2);
							break;
						case 9:
							this.iBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.SelectMiddle(12 + 8 * i, 2).ToBoolArray(), (bool m) => m ? 1 : 0)), num2);
							break;
						case 12:
							this.lBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.SelectMiddle(12 + 8 * i, 2).ToBoolArray(), (bool m) => m ? 1 : 0)), num2);
							break;
						case 13:
							this.mBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.SelectMiddle(12 + 8 * i, 2).ToBoolArray(), (bool m) => m ? 1 : 0)), num2);
							break;
						case 18:
							this.rBuffer.SetBytes(command.SelectMiddle(12 + 8 * i, 2), num2 * 2);
							break;
						case 22:
							this.vBuffer.SetBytes(command.SelectMiddle(12 + 8 * i, 2), num2 * 2);
							break;
						case 23:
							this.wBuffer.SetBytes(command.SelectMiddle(12 + 8 * i, 2), num2 * 2);
							break;
						case 24:
							return this.PackCommandBack(command[0], 3, null);
						case 25:
							this.yBuffer.SetBytes(Enumerable.ToArray<byte>(Enumerable.Select<bool, byte>(command.SelectMiddle(12 + 8 * i, 2).ToBoolArray(), (bool m) => m ? 1 : 0)), num2);
							break;
						case 26:
							this.zBuffer.SetBytes(command.SelectMiddle(12 + 8 * i, 2), num2 * 2);
							break;
						default:
							goto IL_395;
						}
						i++;
						continue;
						IL_395:
						return this.PackCommandBack(command[0], 3, null);
					}
					result = this.PackCommandBack(command[0], 0, null);
				}
			}
			return result;
		}

		// Token: 0x06000563 RID: 1379 RVA: 0x00017DA8 File Offset: 0x00015FA8
		private byte[] StartByCommand(byte[] command)
		{
			this.isProgramStarted = true;
			return this.PackCommandBack(command[0], 0, null);
		}

		// Token: 0x06000564 RID: 1380 RVA: 0x00017DCC File Offset: 0x00015FCC
		private byte[] StopByCommand(byte[] command)
		{
			this.isProgramStarted = false;
			return this.PackCommandBack(command[0], 0, null);
		}

		// Token: 0x06000565 RID: 1381 RVA: 0x00017DF0 File Offset: 0x00015FF0
		private byte[] ReadSystemByCommand(byte[] command)
		{
			bool flag = command[5] == 1;
			byte[] result2;
			if (flag)
			{
				byte[] result = new byte[]
				{
					0,
					this.isProgramStarted ? 1 : 2
				};
				result2 = this.PackCommandBack(command[0], 0, result);
			}
			else
			{
				bool flag2 = command[5] == 2;
				if (flag2)
				{
					byte[] array = new byte[28];
					Encoding.ASCII.GetBytes("F3SP38-6N").CopyTo(array, 0);
					Encoding.ASCII.GetBytes("12345").CopyTo(array, 16);
					array[25] = 17;
					array[26] = 2;
					array[27] = 3;
					result2 = this.PackCommandBack(command[0], 0, array);
				}
				else
				{
					result2 = this.PackCommandBack(command[0], 3, null);
				}
			}
			return result2;
		}

		// Token: 0x06000566 RID: 1382 RVA: 0x00017EA4 File Offset: 0x000160A4
		private byte[] ReadSystemDateTime(byte[] command)
		{
			byte[] array = new byte[16];
			DateTime now = DateTime.Now;
			array[0] = BitConverter.GetBytes(now.Year - 2000)[1];
			array[1] = BitConverter.GetBytes(now.Year - 2000)[0];
			array[2] = BitConverter.GetBytes(now.Month)[1];
			array[3] = BitConverter.GetBytes(now.Month)[0];
			array[4] = BitConverter.GetBytes(now.Day)[1];
			array[5] = BitConverter.GetBytes(now.Day)[0];
			array[6] = BitConverter.GetBytes(now.Hour)[1];
			array[7] = BitConverter.GetBytes(now.Hour)[0];
			array[8] = BitConverter.GetBytes(now.Minute)[1];
			array[9] = BitConverter.GetBytes(now.Minute)[0];
			array[10] = BitConverter.GetBytes(now.Second)[1];
			array[11] = BitConverter.GetBytes(now.Second)[0];
			uint value = (uint)(now - new DateTime(now.Year, 1, 1)).TotalSeconds;
			array[12] = BitConverter.GetBytes(value)[3];
			array[13] = BitConverter.GetBytes(value)[2];
			array[14] = BitConverter.GetBytes(value)[1];
			array[15] = BitConverter.GetBytes(value)[0];
			return this.PackCommandBack(command[0], 0, array);
		}

		// Token: 0x06000567 RID: 1383 RVA: 0x00017FFC File Offset: 0x000161FC
		private byte[] ReadSpecialModule(byte[] command)
		{
			bool flag = command[4] != 0 || command[5] != 1;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 3, null);
			}
			else
			{
				ushort num = this.transform.TransUInt16(command, 6);
				ushort num2 = this.transform.TransUInt16(command, 8);
				result = this.PackCommandBack(command[0], 0, this.specialBuffer.GetBytes((int)(num * 2), (int)(num2 * 2)));
			}
			return result;
		}

		// Token: 0x06000568 RID: 1384 RVA: 0x00018068 File Offset: 0x00016268
		private byte[] WriteSpecialModule(byte[] command)
		{
			bool flag = command[4] != 0 || command[5] != 1;
			byte[] result;
			if (flag)
			{
				result = this.PackCommandBack(command[0], 3, null);
			}
			else
			{
				ushort num = this.transform.TransUInt16(command, 6);
				ushort num2 = this.transform.TransUInt16(command, 8);
				bool flag2 = (int)(num2 * 2) != command.Length - 10;
				if (flag2)
				{
					result = this.PackCommandBack(command[0], 5, null);
				}
				else
				{
					this.specialBuffer.SetBytes(command.RemoveBegin(10), (int)(num * 2));
					result = this.PackCommandBack(command[0], 0, null);
				}
			}
			return result;
		}

		// Token: 0x06000569 RID: 1385 RVA: 0x00018100 File Offset: 0x00016300
		private byte[] PackCommandBack(byte cmd, byte err, byte[] result)
		{
			bool flag = result == null;
			if (flag)
			{
				result = new byte[0];
			}
			byte[] array = new byte[4 + result.Length];
			array[0] = cmd + 128;
			array[1] = err;
			array[2] = BitConverter.GetBytes(result.Length)[1];
			array[3] = BitConverter.GetBytes(result.Length)[0];
			result.CopyTo(array, 4);
			return array;
		}

		/// <inheritdoc />
		// Token: 0x0600056A RID: 1386 RVA: 0x00018160 File Offset: 0x00016360
		protected override void LoadFromBytes(byte[] content)
		{
			bool flag = content.Length < 1310720;
			if (flag)
			{
				throw new Exception("File is not correct");
			}
			this.xBuffer.SetBytes(content, 0, 0, 65536);
			this.yBuffer.SetBytes(content, 65536, 0, 65536);
			this.iBuffer.SetBytes(content, 131072, 0, 65536);
			this.eBuffer.SetBytes(content, 196608, 0, 65536);
			this.mBuffer.SetBytes(content, 262144, 0, 65536);
			this.lBuffer.SetBytes(content, 327680, 0, 65536);
			this.dBuffer.SetBytes(content, 393216, 0, 65536);
			this.bBuffer.SetBytes(content, 524288, 0, 65536);
			this.fBuffer.SetBytes(content, 655360, 0, 65536);
			this.rBuffer.SetBytes(content, 786432, 0, 65536);
			this.vBuffer.SetBytes(content, 917504, 0, 65536);
			this.zBuffer.SetBytes(content, 1048576, 0, 65536);
			this.wBuffer.SetBytes(content, 1179648, 0, 65536);
		}

		/// <inheritdoc />
		// Token: 0x0600056B RID: 1387 RVA: 0x000182BC File Offset: 0x000164BC
		protected override byte[] SaveToBytes()
		{
			byte[] array = new byte[1310720];
			Array.Copy(this.xBuffer.GetBytes(), 0, array, 0, 65536);
			Array.Copy(this.yBuffer.GetBytes(), 0, array, 65536, 65536);
			Array.Copy(this.iBuffer.GetBytes(), 0, array, 131072, 65536);
			Array.Copy(this.eBuffer.GetBytes(), 0, array, 196608, 65536);
			Array.Copy(this.mBuffer.GetBytes(), 0, array, 262144, 65536);
			Array.Copy(this.lBuffer.GetBytes(), 0, array, 327680, 65536);
			Array.Copy(this.dBuffer.GetBytes(), 0, array, 393216, 65536);
			Array.Copy(this.bBuffer.GetBytes(), 0, array, 524288, 65536);
			Array.Copy(this.fBuffer.GetBytes(), 0, array, 655360, 65536);
			Array.Copy(this.rBuffer.GetBytes(), 0, array, 786432, 65536);
			Array.Copy(this.vBuffer.GetBytes(), 0, array, 917504, 65536);
			Array.Copy(this.zBuffer.GetBytes(), 0, array, 1048576, 65536);
			Array.Copy(this.wBuffer.GetBytes(), 0, array, 1179648, 65536);
			return array;
		}

		/// <inheritdoc />
		// Token: 0x0600056C RID: 1388 RVA: 0x00018450 File Offset: 0x00016650
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				SoftBuffer softBuffer = this.xBuffer;
				if (softBuffer != null)
				{
					softBuffer.Dispose();
				}
				SoftBuffer softBuffer2 = this.yBuffer;
				if (softBuffer2 != null)
				{
					softBuffer2.Dispose();
				}
				SoftBuffer softBuffer3 = this.iBuffer;
				if (softBuffer3 != null)
				{
					softBuffer3.Dispose();
				}
				SoftBuffer softBuffer4 = this.eBuffer;
				if (softBuffer4 != null)
				{
					softBuffer4.Dispose();
				}
				SoftBuffer softBuffer5 = this.mBuffer;
				if (softBuffer5 != null)
				{
					softBuffer5.Dispose();
				}
				SoftBuffer softBuffer6 = this.lBuffer;
				if (softBuffer6 != null)
				{
					softBuffer6.Dispose();
				}
				SoftBuffer softBuffer7 = this.dBuffer;
				if (softBuffer7 != null)
				{
					softBuffer7.Dispose();
				}
				SoftBuffer softBuffer8 = this.bBuffer;
				if (softBuffer8 != null)
				{
					softBuffer8.Dispose();
				}
				SoftBuffer softBuffer9 = this.fBuffer;
				if (softBuffer9 != null)
				{
					softBuffer9.Dispose();
				}
				SoftBuffer softBuffer10 = this.rBuffer;
				if (softBuffer10 != null)
				{
					softBuffer10.Dispose();
				}
				SoftBuffer softBuffer11 = this.vBuffer;
				if (softBuffer11 != null)
				{
					softBuffer11.Dispose();
				}
				SoftBuffer softBuffer12 = this.zBuffer;
				if (softBuffer12 != null)
				{
					softBuffer12.Dispose();
				}
				SoftBuffer softBuffer13 = this.wBuffer;
				if (softBuffer13 != null)
				{
					softBuffer13.Dispose();
				}
				SoftBuffer softBuffer14 = this.specialBuffer;
				if (softBuffer14 != null)
				{
					softBuffer14.Dispose();
				}
			}
			base.Dispose(disposing);
		}

		/// <inheritdoc />
		// Token: 0x0600056D RID: 1389 RVA: 0x0001856C File Offset: 0x0001676C
		public override string ToString()
		{
			return string.Format("YokogawaLinkServer[{0}]", base.Port);
		}

		// Token: 0x0400016C RID: 364
		private SoftBuffer xBuffer;

		// Token: 0x0400016D RID: 365
		private SoftBuffer yBuffer;

		// Token: 0x0400016E RID: 366
		private SoftBuffer iBuffer;

		// Token: 0x0400016F RID: 367
		private SoftBuffer eBuffer;

		// Token: 0x04000170 RID: 368
		private SoftBuffer mBuffer;

		// Token: 0x04000171 RID: 369
		private SoftBuffer lBuffer;

		// Token: 0x04000172 RID: 370
		private SoftBuffer dBuffer;

		// Token: 0x04000173 RID: 371
		private SoftBuffer bBuffer;

		// Token: 0x04000174 RID: 372
		private SoftBuffer fBuffer;

		// Token: 0x04000175 RID: 373
		private SoftBuffer rBuffer;

		// Token: 0x04000176 RID: 374
		private SoftBuffer vBuffer;

		// Token: 0x04000177 RID: 375
		private SoftBuffer zBuffer;

		// Token: 0x04000178 RID: 376
		private SoftBuffer wBuffer;

		// Token: 0x04000179 RID: 377
		private SoftBuffer specialBuffer;

		// Token: 0x0400017A RID: 378
		private const int DataPoolLength = 65536;

		// Token: 0x0400017B RID: 379
		private IByteTransform transform;

		// Token: 0x0400017C RID: 380
		private bool isProgramStarted = false;
	}
}
